<%--
  Created by IntelliJ IDEA.
  User: libowu
  Date: 18-10-15
  Time: 下午5:14
  To change this template use File | Settings | File Templates.
--%>
<%--<%@ page contentType="text/html;charset=UTF-8" language="java"  %>--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><!-- 引入jstl库 -->
<html>
    <meta charset="UTF-8">
    <title>${config.webtitle}</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/sysCss/index.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <script src="/js/sysJs/index.js"></script>


</head>


<body id="body">

<div class="container-fluid parent">
    <div class="row">
        <!--顶部导航条-->
        <div class="row topBar" id="topBar" style="display: flex">

            <!--已打开的应用-->
            <div style="height: 100%;flex: 1" id="fu-app-item" style="position: relative">
                <div class="fu-mission-item d-none d-lg-block" data-name='首页'>
                    <label class="topBarContent activityMission"  onclick="openMission('首页',this)" data-name='首页'>
                        <span>首页</span>
                    </label>
                    <img src="/img/appLogo/back.png" width="16" class="fu-back-btn" onclick="removeMission('首页')"/>
                </div>

            </div>

            <!--当前用户-->
            <div style="text-align: center;width: 180px;line-height: 50px;padding-top: 5px">

                <!--当前用户头像-->
                <div class="userImg">

                </div>

                <div class="dropdown">
                    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                        ${sessionScope.name}
                    </button>
                    <div class="dropdown-menu">

                        <a class="dropdown-item" onclick="openApp('/futer/userSetting','用户设置')">用户设置</a>

                        <c:if test="${config.hideuseradmin!=1}">
                            <a class="dropdown-item" onclick="openApp('/futer/userAdmin','用户管理')">用户管理</a>
                        </c:if>

                        <c:if test="${config.hideuseradmin==1}">
                            <c:if test="${sessionScope.type=='admin'}">
                                <a class="dropdown-item" onclick="openApp('/futer/userAdmin','用户管理')">用户管理</a>
                            </c:if>
                        </c:if>

                        <c:if test="${config.hideappsetting!=1}">
                            <a class="dropdown-item" onclick="openApp('/futer/appSetting','应用设置')">应用设置</a>
                        </c:if>

                        <c:if test="${config.hideappsetting==1}">
                            <c:if test="${sessionScope.type=='admin'}">
                                <a class="dropdown-item" onclick="openApp('/futer/appSetting','应用设置')">应用设置</a>
                            </c:if>
                        </c:if>

                        <c:if test="${sessionScope.type=='admin'}">
                            <a class="dropdown-item" onclick="openApp('/futer/setting','框架设置')">框架设置</a>
                        </c:if>
                        <a class="dropdown-item" href="loginOut">退出登录</a>
                        <a class="dropdown-item" href="loginOut">注销</a>

                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class="row" style="display: flex;height: 100%;padding: 0;">
        <div class="d-none d-lg-block fu-leftcontent" id="left" style="width: 80px">
            <div class="bottomBar" id="bottomBar">
                <div class="application">
                    <ul id="app">

                        <c:if test="${application.size()!=0}">
                            <c:forEach items="${application}" var="app">
                                <c:if test="${app.appname=='首页'}">
                                    <li class="appMission" onclick="openApp('${app.appurl}','${app.appname}')">
                                        <div class="fu-appimgparent">
                                            <img src="${app.appimg}"/>
                                        </div>
                                        <span style="font-size: 12px">${app.appname}</span>
                                        <div class="markOpen active" data-name="${app.appname}"></div>
                                    </li>
                                </c:if>

                                <c:if test="${app.appname!='首页'}">
                                    <li class="appMission" onclick="openApp('${app.appurl}','${app.appname}')">
                                        <div class="fu-appimgparent">
                                            <img src="${app.appimg}"/>
                                        </div>
                                        <span style="font-size: 12px">${app.appname}</span>
                                        <div class="markOpen" data-name="${app.appname}"></div>
                                    </li>
                                </c:if>

                            </c:forEach>
                        </c:if>


                    </ul>
                </div>
            </div>
        </div>
        <div id="showContent" style="flex: 1;height: 100%">
            <iframe src="/futer/home" frameborder="no" scrolling="auto" id="futermarket" allowtransparency="true" class="app active" data-name="首页" style="width: 100%;margin: 0 auto;height: 100%;"></iframe>
        </div>
    </div>
</div>


<script type="text/javascript">

    (document.getElementById("body")).style.backgroundColor="${config.bgforframe}";
    (document.getElementById("bottomBar")).style.backgroundColor="${config.bgforappbar}";
    (document.getElementById("topBar")).style.backgroundColor="${config.bgformissionbar}";
    var span=document.getElementsByTagName("span");
    for (var i=0;i<span.length;i++){
        span[i].style.color="${config.fontcolor}";
    }


    function sengToLogin(){
        window.location.href="/futer/login";
    }

    function loadCss(){
        $.ajax({
            type: "post",
            url: "/futer/reLoadCss",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {

                if (response=='请求被拒绝，无权限访问'){
                    parent.sengToLogin();
                    return;
                }

                (document.getElementById("body")).style.backgroundColor=response.bgforframe;
                (document.getElementById("bottomBar")).style.backgroundColor=response.bgforappbar;
                (document.getElementById("topBar")).style.backgroundColor=response.bgformissionbar;
                var span=document.getElementsByTagName("span");
                for (var i=0;i<span.length;i++){
                    span[i].style.color=response.fontcolor;
                }
            }, error: function (err) {
                alert("修改失败！");
            }
        })

    }

    /**
     * 刷新ａｐｐ栏目
     */
    function reFreshApp(name,type){
        $.ajax({
            type: "post",
            url: "/futer/getApp",
            dataType: "json",
            success: function (response) {
                console.log("成功"+JSON.stringify(response));
                var activityPosition = -1;
                $("#app").empty();
                $.each(response, function(index, item){
                    if (item.appname == name){
                        activityPosition = index;
                    }

                    $("#app").append("<li class=\"appMission\" onclick=\"openApp('"+item.appurl+"','"+item.appname+"')\">\n" +
                        "                                        <div class=\"fu-appimgparent\">\n" +
                        "                                            <img src='"+item.appimg+"'>\n" +
                        "                                        </div>\n" +
                        "                                        <span style=\"font-size: 12px\">"+item.appname+"</span>\n" +
                        "                                        <div class=\"markOpen\" data-name='"+item.appname+"'></div>\n" +
                        "                                    </li>");
                });
                if (activityPosition!=-1){
                    var activity = document.getElementsByClassName("markOpen");
                    activity[activityPosition].className = 'markOpen active';
                }


            }, error: function (err) {
                console.log("错误日志："+err);
            }
        })
    }



</script>
</body>
</html>
